﻿package top.yangyitao.action;

import javax.annotation.Resource;

import com.opensymphony.xwork2.ActionSupport;

import top.yangyitao.model.User;
import top.yangyitao.service.UserService;

@SuppressWarnings("serial")
public class UpdatePWD extends ActionSupport {

	@Resource
	private UserService userService;
	
	private String errorMessage;
	private String userName;
	private String password;
	private String checkPassword;
	public String getErrorMessage() {
		return errorMessage;
	}
	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getCheckPassword() {
		return checkPassword;
	}
	public void setCheckPassword(String checkPassword) {
		this.checkPassword = checkPassword;
	}
	@Override
	public String execute() throws Exception {
		if(!password.equals(checkPassword)) {
			errorMessage = "*两次输入的密码不一致!";
			return ERROR;
		}
		else {
			User user = new User();
			user.setUserName(userName);
			user.setPassword(password);
			userService.updateUserOfPassword(user);
			errorMessage = "*重置成功!";
			return SUCCESS;
		}
	}

}
